//
//  HMListCaoweiViewController.m
//  G05爱鲜蜂
//
//  Created by 源 何 on 16/10/21.
//  Copyright © 2016年 何源. All rights reserved.
//

#import "HMListCaoweiViewController.h"

#import "HMTableFootView.h"
#import "PayTableViewController.h"
#import "Masonry.h"
#import "HMUITableView.h"
#import "HMHomeViewController.h"
@interface HMListCaoweiViewController ()
@property (nonatomic, strong) HMTableFootView *footView;
@property (nonatomic,strong) HMUITableView *listTableView;
@end

@implementation HMListCaoweiViewController

-(HMUITableView *)listTableView{
    if (_listTableView == nil) {
        _listTableView = [[HMUITableView alloc]init];
        
    }
    return _listTableView;
}

-(HMTableFootView *)footView{
    if (_footView == nil) {
        _footView = [[HMTableFootView alloc]init];
    }
    return _footView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *leftBtn = [UIButton ff_buttonWithTitle:@"" imageName:@"v2_goback" target:self action:@selector(dismiss)];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
    self.title = @"购物车";
    
    [self setupSubviews];
    [self commitDidClick];
}

- (void)dismiss{

    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

-(void)setupSubviews {
    
    [self.view addSubview:self.footView];
    [self.footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view).offset(-20);
        make.height.equalTo(@50);
    }];
    
    
    [self.view addSubview:self.listTableView];
    [self.listTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.left.equalTo(self.view);
        make.top.equalTo(self.view).offset(64);
        make.bottom.equalTo(self.footView.mas_top);
        
    }];
    
}

-(void)commitDidClick {
    
    __weak HMListCaoweiViewController *weakListVC = self;
    self.footView.commitBlock = ^() {
        PayTableViewController *payVC = [[PayTableViewController alloc]init];
        [weakListVC.navigationController pushViewController:payVC animated:YES];
        //        weakListVC.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"v2_goback"] style:UIBarButtonItemStylePlain target:self action:nil];
    };
}

@end
